package com.suxin.socket.yinfei;

import com.suxin.socket.yinfei.pusher.DefaultPusherHandler;
import com.suxin.socket.yinfei.session.ParameterSessionConnectionHolder;
import com.suxin.socket.yinfei.session.SessionConnectionHolder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import javax.websocket.server.ServerEndpoint;

/**
 * @author Tang
 * @classname PageDataConnection
 * @description [ 页面数据 ]
 * @date 2021/8/17 22:29
 */
@Component
@ServerEndpoint(value = "/page/data/{deviceId}")
public class PageDataConnection extends AbstractWebSocketConnection {

    private static SessionConnectionHolder sessionConnectionHolder = new ParameterSessionConnectionHolder(new String[]{"deviceId"});

    @Override
    protected SessionConnectionHolder getSessionConnectionHolder() {
        return sessionConnectionHolder;
    }

    @Configuration
    public static class PageDataConnectionPusher{

        @Bean
        public DefaultPusherHandler pageDataPusher() {
            return new DefaultPusherHandler(sessionConnectionHolder);
        }

    }

}